<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue8双向数据绑定指令</title>
  </head>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.8"></script>
  <body>
    <div id="app">
        <p>用户的名字是:{{username}}</p>
        <!-- 双向数据绑定 只能用在文本框，表单里面-->
        <input type="text" v-model = "username"/> 
        <hr>
        <select name="" id=""  v-model="city">
            <option value="">请选择城市</option>
            <option value="1">江苏</option>
            <option value="2">河南</option>
            <option value="3">深圳</option>
            <option value="4">上海</option>
            <option value="5">深圳</option>
            <option value="6">湖南</option>
        </select>
        <p>{{city}}</p>
        <button @click="showValue">显示cicty绑定的option的值</button>
    </div>
    <script>
      const vm = new Vue({
        el: "#app",
        data: {
            username:"zhangsanww",
            // 默认值city的值是上海 ，数据的双向绑定是真的很神奇！！！！
            city:"1" 
        },
        methods: {
            showValue(e){
                alert(this.city);
            }
        },
      });
    </script>
  </body>
</html>
